<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>替换内容不复用</title>
    <style>
        
    </style>
</head>
<body>
    <div id="app">
        <span v-if="type==='name'">
            <label for="" key="name-lable">用户名: </label>
            <input placeholder="输入用户名" key="name-input">
        </span>
        <span v-else>
            <label for="">密码: </label>
            <input placeholder="输入邮箱" key="mail-input">
        </span>
        <button @click="handleToggleClick">切换输入类型</button>
    </div>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script>
        let app = new Vue({
            el: '#app',
            data(){
                return {
                    type: 'name'
                }
            },
            methods:{
                handleToggleClick: function(){
                    this.type = this.type === 'name' ? 'mail' : 'name';
                }
            }
        })
    </script>
</body>
</html>